<!DOCTYPE html>
<html lang="en" class="h-100">

<head>
    <meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="keywords" content="">
	<meta name="author" content="">
	<meta name="robots" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="Innap : Hotel Admin Template">
	
	<!-- PAGE TITLE HERE -->
	<title>导检员登录</title>
	
    <link href="static/css/style.css" rel="stylesheet">
	<script src="static/js/vue.min.js"></script>

</head>

<body class="vh-100">
    <div class="authincation h-100">
        <div class="container h-100">
            <div class="row justify-content-center h-100 align-items-center" id="app">
                <div class="col-md-6">
                    <div class="authincation-content">
                        <div class="row no-gutters">
                            <div class="col-xl-12">
                                <div class="auth-form">
									<div class="text-center mb-3">
										<a href="main.html"><img src="" alt=""></a>
									</div>
                                    <h4 class="text-center mb-4">欢迎登录体检平台</h4>
                                    <form action="main.html">
                                        <div class="mb-3">
                                            <label class="mb-1"><strong>用户名</strong></label>
                                            <input type="text" class="form-control" v-model="account" value="" name="account" id="account" placeholder="请输入用户名">
                                        </div>
                                        <div class="mb-3">
                                            <label class="mb-1"><strong>登录密码</strong></label>
                                            <input type="password" class="form-control" v-model="password" value="" name="password" id="password" placeholder="请输入登录密码">
                                        </div>
                                        <div class="mb-3">
                                            <label class="mb-1"><strong>验证码</strong></label>
                                            <br>
                                            <input type="text" class="form-control" v-model="code" value="" placeholder="请输入验证码" name="code" id="code" style="width:50%;float:left">
                                            <img src="Code/getCode" style="float:left;width:50%;height:2.75rem;padding: 0.3125rem 1.25rem;" onclick="changeCode(this)"/>
                                        </div>
                                        <br>
                                        <div class="row d-flex justify-content-between mt-4 mb-2">
                                            <div class="mb-3">
                                               <div class="form-check custom-checkbox ms-1">
													
													<label class="form-check-label" for="basic_checkbox_1"></label>

												</div>
                                            </div>

                                        </div>
                                        <div class="text-center">
                                            <button type="button" class="btn btn-primary btn-block" @click="login">登录</button>
                                        </div>
                                    </form>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

	
    <!--**********************************
        Scripts
		
    ***********************************-->
	
	<script>
		new Vue({
		 el: '#app',
		  data: {
		    account: '',
		    password: '',
		    code: ''
		  },
		  methods: {
		    login: function() {
		     
		       $.ajax({
		         url: 'adminUser/login',
		         type: 'POST',
		         data: {
					 account:this.account,
					 password:this.password,
					 code:this.code,
				 },
		         success: function(response) {
		           let datas = JSON.parse(response);
		           
		           	// console.log(datas)
		           if (datas.statusCode == 200) {
		               let user = JSON.stringify(datas.datas.user);
		           
		               sessionStorage.setItem("user", user);
		           
		               alert(datas.errMsg);
		           	
		           	
						location.href="href?to="+datas.location;	
		              
		           
		           
		           } else {
		               alert(datas.errMsg)
		           }
		         },
		         error: function(xhr, status, error) {
		           console.error('Error:', error);
		         }
		       });
		    }
		  }
		})
	</script>
	<script>
	    function changeCode(param) {
	    console.log(param);
	    param.src = 'Code/getCode'+'?'+Math.random();
	}
	</script>
    <!-- Required vendors -->
    <script src="static/js/global.min.js"></script>
    <script src="static/js/custom.min.js"></script>
    <script src="static/js/deznav-init.js"></script>
	<script src="static/js/styleSwitcher.js"></script>
    <script src="static/js/jquery.js"></script>
    <script src="static/js/api.js"></script>
</body>
</html>